package com.breakfast.fun.ui.user.feedback;

import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.breakfast.fun.Constant;
import com.breakfast.fun.R;
import com.breakfast.fun.base.BaseActivity;
import com.breakfast.fun.data.entity.user.feedback.FeedData;
import com.breakfast.fun.util.EncyptUtil;
import com.breakfast.fun.util.L;
import com.breakfast.fun.util.T;
import com.breakfast.fun.view.widget.TitleBarView;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;

public class FeedBackActivity extends BaseActivity<FeedBackPresenter, FeedBackModel> implements FeedBackContract.View {


    @Bind(R.id.tbv_feedback)
    TitleBarView tbvFeedback;
    @Bind(R.id.et_feedback_content)
    EditText etFeedbackContent;
    @Bind(R.id.et_feedback_name)
    EditText etFeedbackName;
    @Bind(R.id.et_feedback_mobile)
    EditText etFeedbackMobile;
    @Bind(R.id.btn_feedback_submit)
    Button btnFeedbackSubmit;

    @Override
    public int getLayoutId() {
        return R.layout.activity_feed_back;
    }

    @Override
    public void initView() {
        tbvFeedback.setTitleNoRight("意见反馈");
        tbvFeedback.setBack(this);

        btnFeedbackSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(etFeedbackContent.getText().toString().trim())
                        || TextUtils.isEmpty(etFeedbackMobile.getText().toString().trim())
                        || TextUtils.isEmpty(etFeedbackName.getText().toString().trim())) {
                    T.show("信息不完整，请检查");
                    return;
                }
                FeedData feedData = new FeedData(etFeedbackName.getText().toString()
                        , etFeedbackMobile.getText().toString(), etFeedbackContent.getText().toString());
                presenter.submitFeed(feedData);
            }
        });
    }


    @Override
    public void feedSuccess() {
        FeedBackActivity.this.finish();
        T.show("感谢您的反馈,我们会更加努力做到更好的!");
    }
}
